#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/4/14  13:56
# @Author: 余浪人
# @email: yulangren520@gmail.com
from flask_login import UserMixin

from apps.models import  BaseModel,db


# 权限管理
class Authority_Model(BaseModel):
    authority_name = db.Column(db.String(64), comment='权限名称')

    def keys(self):
        return 'authority_name',


class Admin_Model(BaseModel,UserMixin):
    username = db.Column(db.String(64), comment='登陆名')
    password = db.Column(db.String(512), comment='密码')
    remark = db.Column(db.String(512), comment='备注')
    authority = db.Column(db.Integer,db.ForeignKey(Authority_Model.id),comment='权限')
    pro = db.relationship('Authority_Model', backref='admin_model')

    def __repr__(self):
        return f'当前管理员<{self.username}>'

    def keys(self):
        return 'username', 'remark', 'authority', 'status', 'create_time',
